package com.chenyongjing.design.pattern.composite.general.transparent;

import java.util.ArrayList;
import java.util.List;

/**
 * 脱敏实现
 */
public class Composite extends Component{
    private List<Component> mComponent;

    public Composite(String name) {
        super(name);
        this.mComponent = new ArrayList<Component>();
    }

    @Override
    public String opertion() {
        StringBuilder builder = new StringBuilder(this.name);
        for(Component component :this.mComponent){
            builder.append("\n");
            builder.append(component.opertion());
        }
        return builder.toString();
    }

    @Override
    public boolean addChild(Component component) {
        return super.addChild(component);
    }

    @Override
    public boolean removeChild(Component component) {
        return super.removeChild(component);
    }

    @Override
    public Component getChild(int index) {
        return super.getChild(index);
    }
}
